import commonList from '@/components/common/commonList'
export default {

	data() {
		return {
			Inv: 0,
			tableData: [],
			userInfo: {},
			table_config: [{
					label: "样品编号",
					prop: "fSampleassignnostr",
					isLine: false,
				},
				{
					label: "信息状态",
					prop: "fStatus",
					isLine: false,
				},
				{
					label: "试验名称",
					prop: "fSamplereportname",
					isLine: true,
				},

				{
					label: "项目简称",
					prop: "fProjectname",
					isLine: true,
				},
				{
					label: "报告编号",
					prop: "fSamplereportnostr",
					isLine: true,
				},
				{
					label: "报告日期",
					prop: "fReportdates",
					isLine: true,
				},


			],
			dataList: {
				fCompanyid: "", // 左侧选中组织机构id
				keyWord: "", // 试验名称、报告编号、工程部位/用途
				keyType: "", // 检测类型
				modelType: "0", // 0待办 1已办 2查询
				page: 1, // 当前页码
				pageSize: 20, // 每页显示条数
				userId: "", // 查询待办或已办时传 列表页查询不传
				startDates: "", // 开始时间
				endDates: "", // 截至时间
			},

		}
	},
	components: {
		commonList,
	},
	onLoad(option) {
		var that = this;

		if (option.Inv) {
			this.Inv = option.Inv;
		}

		uni.getStorage({
			key: 'userInfo',
			success: function(res) {
				that.userInfo = JSON.parse(res.data);
				// that.getExamine(that.userInfo.companyId);
				that.yj_searchForm(that.Inv);
			}
		})
	},
	onShow() {
		var that = this
		if (that.Inv == 0) {
			setTimeout(() => {
				that.unsubmit()
			}, 300)
		}
		if (that.Inv == 1) {
			setTimeout(() => {
				that.submit()
			}, 300)
		}
	},

	// 新增
	onNavigationBarButtonTap(e) {},
	// 返回
	onBackPress(event) {
		uni.switchTab({
			url: '/pages/home/index'
		});
		return true;
	},

	methods: {
		unsubmit() {
			var that = this;
			this.Inv = 0;
			this.yj_searchForm(this.Inv);
		},
		submit() {
			var that = this;
			this.Inv = 1;
			this.yj_searchForm(this.Inv);
		},
		
		// 获取列表
		yj_searchForm(num) {
			num = num.toString()
			this.dataList = {
				fCompanyid: this.userInfo.companyId, //左侧选中组织机构id
				userId: this.userInfo.userId, //查询待办或已办时传 列表页查询不传
				keyWord: "", // 试验名称、报告编号、工程部位/用途
				keyType: "", // 检测类型
				modelType: num, // 0待办 1已办 2查询
				page: 1, // 当前页码
				pageSize: 20, // 每页显示条数
				startDates: "", // 开始时间
				endDates: "", // 截至时间
			};
			this.$http.getInspectionFormWebList(this.dataList).then(res => {
				if (res.errcode == 0) {
					var that = this;
					that.tableData = [];
					that.tableData = res.data.pageInfo.list;
				} else {
					console.log("接口报错")
				}
			}, (err) => {
				uni.showToast({
					title: "获取数据失败",
					icon: 'none',
					duration: 2000
				});
			})
		},
		// 查看
		yj_viewForm(e) {
			if (e.Inv == 0) {
				uni.navigateTo({
					url: "/pages/apply/testDetectionManage/InspectionForm/inter/index?row=" + e.item
				});
				return false;
			}
			if (e.Inv == 1) {
				uni.navigateTo({
					url: "/pages/apply/testDetectionManage/InspectionForm/submit/index?id=" + e.id
				});
				return false;
			}
		},
	}
}
